package com.edu.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Locale;

/**
 * ClassName:MyMvcConfig
 * Package:com.edu.config
 * Description:扩展 spring MVC  dispatchservlet
 * Date:2020/5/26 15:17
 * User: snow
 */
// 扩展spring MVC
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {

	// ViewResolver 实现类视图解析器接口的类，我们就可以把它看做视图解析器

	@Bean
	public ViewResolver myViewResolver() {
		return new MyViewResolver();
	}

	/**
	 * 自定义视图解析器
	 */
	public static class MyViewResolver implements ViewResolver {

		@Override
		public View resolveViewName(String viewName, Locale locale) throws Exception {
			return null;
		}
	}


	// 视图跳转
	@Override
	public void addViewControllers(ViewControllerRegistry registry) {
		// 控制跳转路径   localhost8080/edu   localhost8080/index
		registry.addViewController("/edu").setViewName("index");
	}
}




